#ifndef __MYFLASH_H_
#define __MYFLASH_H_

#include "stm32f4xx_hal.h"

/*flash information macro*/
#define     flash_address       (uint32_t)0x08000000
#define     flash_size          (uint32_t)0x00100000

/*sector map*/
#define     sector0_address     (uint32_t)0x08000000
#define     sector1_address     (uint32_t)0x08004000
#define     sector2_address     (uint32_t)0x08008000
#define     sector3_address     (uint32_t)0x0800C000

#define     sector4_address     (uint32_t)0x08010000

#define     sector5_address     (uint32_t)0x08020000
#define     sector6_address     (uint32_t)0x08040000
#define     sector7_address     (uint32_t)0x08060000
#define     sector8_address     (uint32_t)0x08080000
#define     sector9_address     (uint32_t)0x080A0000
#define     sector10_address    (uint32_t)0x080C0000
#define     sector11_address    (uint32_t)0x080E0000

/*application information macro*/
#define     application_address (uint32_t)0x08004000
#define     user_size           (uint32_t)0x0001C000

/* procedure flag */
#define		flag_address		sector5_address
#define		pro_flag			(uint32_t)0x72116666

typedef  void (*iapfun)(void);              //����һ���������͵Ĳ���.
/*function defined */
void flash_init(void);
static uint32_t sector_location(const uint32_t address);
HAL_StatusTypeDef flash_program(uint32_t address,uint32_t const * data,const uint32_t len);
HAL_StatusTypeDef flash_erase(uint32_t address,uint32_t size);
void iap_load_app(uint32_t appxaddr);
#endif
